﻿// <copyright file="IPoint2DSeries.cs" company="Oleg V. Polikarpotchkin">
// Copyright © 2008-2009 Oleg V. Polikarpotchkin. All Right Reserved
// </copyright>
// <author>Oleg V. Polikarpotchkin</author>
// <email>ov-p@yandex.ru</email>
// <date>2009-04-18</date>
// <summary>OpenWPFChart library. 2D Point Series generic Interfaces.</summary>
// <revision>$Id$</revision>

using System;
using System.Collections.Generic;

namespace OpenWPFChart.Parts
{
	/// <summary>
	/// Generic 2D Point.
	/// </summary>
	struct Point2D
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="Point2D"/> struct.
		/// </summary>
		/// <param name="x">The abscissa.</param>
		/// <param name="y">The ordinate.</param>
		public Point2D(object x, object y)
			: this()
		{
			X = x;
			Y = y;
		}

		/// <summary>
		/// Gets the abscissa.
		/// </summary>
		/// <value>The abscissa.</value>
		public object X { get; private set; }

		/// <summary>
		/// Gets the ordinate.
		/// </summary>
		/// <value>The ordinate.</value>
		public object Y { get; private set; }

		#region object overrides
		/// <summary>
		/// Indicates whether this instance and a specified object are equal.
		/// </summary>
		/// <param name="obj">Another object to compare to.</param>
		/// <returns>
		/// true if <paramref name="obj"/> and this instance are the same type and represent the same value; otherwise, false.
		/// </returns>
		public override bool Equals(object obj)
		{
			if (obj == null || obj.GetType() != typeof(Point2D))
				return false;
			Point2D pt = (Point2D)obj;
			return (X.Equals(pt.X) && Y.Equals(pt.Y));
		}

		/// <summary>
		/// Returns the hash code for this instance.
		/// </summary>
		/// <returns>
		/// A 32-bit signed integer that is the hash code for this instance.
		/// </returns>
		public override int GetHashCode()
		{
			return (X.GetHashCode() ^ Y.GetHashCode());
		}

		/// <summary>
		/// Returns this instance string representation.
		/// </summary>
		/// <returns>this instance <see cref="T:System.String"/> representation.</returns>
		public override string ToString()
		{
			return string.Format("({0},{1})", X, Y);
		}
		#endregion object overrides
	}

	/// <summary>
	/// 2D Data Point Series Interface.
	/// </summary>
	interface IPoint2DSeries
	{
		/// <summary>
		/// Gets the generic 2D Point.
		/// </summary>
		/// <value>2D points.</value>
		IEnumerable<Point2D> Points { get; }
	}
}
